<meta charset="utf-8">

<meta http-equiv="X-UA-Compatible" content="IE=edge">

<meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
<title>基本地图展示</title>
<link rel="stylesheet" href="http://cache.amap.com/lbs/static/main1119.css"/>
<script src="http://cache.amap.com/lbs/static/es5.min.js"></script>
<script src="http://webapi.amap.com/maps?v=1.4.3&key=0a755c18011bc4ce0f9635e6cb167f94"></script>
<script type="text/javascript" src="http://cache.amap.com/lbs/static/addToolbar.js"></script>
<div id="container"></div>

<script>
    function gddata(data){
        container.innerHTML = data.regeocode.addressComponent.city;
    }
</script>
<script src="http://restapi.amap.com/v3/geocode/regeo?key=e6c59e6cb1d87cf924b4d03336061c50&location=117.292894345,31.850076399999995&callback=gddata"></script>



<script>
    if (navigator && navigator.geolocation && navigator.geolocation.getCurrentPosition) {
        navigator.geolocation.getCurrentPosition(function(ret) {
                window.longitude = ret.coords.longitude;
                window.latitude = ret.coords.latitude;

                console.log(longitude);
                console.log(latitude);

                  var map = new AMap.Map('container', {
                      resizeEnable: true,
                      zoom:17,
                      center: [longitude, latitude]
                  });

                //这个key web服务的key
                //http://restapi.amap.com/v3/geocode/regeo?key=e6c59e6cb1d87cf924b4d03336061c50&location=117.292894345,31.850076399999995
                //返回值是城市

            }, function(ret) {},
            {
                //开启高精度定位
                enableHighAccuracy : true,
                timeout : 2000,
                maximumAge : 300000
            });
    }

</script>
